home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue60 / ClassEng / Listing5.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2000-06-28  |  2.0 KB  |  69 lines

  1. TMyBars = class
  2. private
  3.   FooBars: TList;
  4.   CandyBars: TList;
  5.   SandBars: TList;
  6.   WineBars: TList;
  7.   function GetBarCount(Index: Integer): Integer;
  8.   function GetBar(Item: Integer; Index: Integer): Pointer;
  9.   procedure SetBarCount(Index: Integer; Value: Integer);
  10.   procedure SetBar(Item: Integer; Index: Integer; Value: Pointer);
  11. public
  12.   property FooBarCount: Integer     index 0 
  13.       read GetBarCount write SetBarCount;
  14.   property CandyBarCount: Integer   index 1 
  15.       read GetBarCount write SetBarCount;
  16.   property SandBarCount: Integer    index 2 
  17.       read GetBarCount write SetBarCount;
  18.   property WineBarCount: Integer    index 3 
  19.       read GetBarCount write SetBarCount;
  20.   property FooBar[Item: Integer]: Pointer   index 0 
  21.       read GetBar write SetBar;
  22.   property CandyBar[Item: Integer]: Pointer index 1 
  23.       read GetBar write SetBar;
  24.   property SandBar[Item: Integer]: Pointer  index 2 
  25.       read GetBar write SetBar;
  26.   property WineBar[Item: Integer]: Pointer  index 3 
  27.       read GetBar write SetBar;
  28. end;
  29. . . .
  30. function TMyBars.GetBar(Item, Index: Integer): Pointer;
  31. begin
  32.   case Index of
  33.     0: Result := FooBars[Item];
  34.     1: Result := CandyBars[Item];
  35.     2: Result := SandBars[Item];
  36.   else
  37.     Result := WineBars[Item];
  38.   end;
  39. end;
  40. function TMyBars.GetBarCount(Index: Integer): Integer;
  41. begin
  42.   case Index of
  43.     0: Result := FooBars.Count;
  44.     1: Result := CandyBars.Count;
  45.     2: Result := SandBars.Count;
  46.   else
  47.     Result := WineBars.Count;
  48.   end;
  49. end;
  50. procedure TMyBars.SetBar(Item, Index: Integer; Value: Pointer);
  51. begin
  52.   case Index of
  53.     0: FooBars[Item] := Value;
  54.     1: CandyBars[Item] := Value;
  55.     2: SandBars[Item] := Value;
  56.   else
  57.      WineBars[Item] := Value;
  58.   end;
  59. end;
  60. procedure TMyBars.SetBarCount(Index, Value: Integer);
  61. begin
  62.   case Index of
  63.     0: FooBars.Count := Value;
  64.     1: CandyBars.Count := Value;
  65.     2: SandBars.Count := Value;
  66.   else
  67.      WineBars.Count := Value;
  68.   end;
  69. end;